package com.edu.whty.service.impl;


import com.edu.whty.common.tools.MapUtils;
import com.edu.whty.dao.RepoCatalogResourceDao;
import com.edu.whty.entity.base.Pagination;
import com.edu.whty.entity.school.RepoCatalogResource;
import com.edu.whty.service.RepoCatalogResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("repoCatalogResourceService")
public class RepoCatalogResourceServiceImpl implements RepoCatalogResourceService {
	
	@Autowired
	private RepoCatalogResourceDao repoCatalogResourceDao;


	@Override
	public List<RepoCatalogResource> getResByCatalogIdInPage(RepoCatalogResource catalogResParam, Pagination pagination) {
		return repoCatalogResourceDao.getResByCatalogIdInPage(catalogResParam,pagination);
	}

	@Override
	public Map<String, Object> getConfigSpecialRepoCountInfo(RepoCatalogResource param) {
		return repoCatalogResourceDao.getConfigSpecialRepoCountInfo(param);
	}

	@Override
	public List<Map<String, Object>> countFourRepoResNum(Map<String, Object> param) {
		return repoCatalogResourceDao.countFourRepoResNum(param);
	}

	@Override
	public void insert(RepoCatalogResource record) {
		repoCatalogResourceDao.insert(record);

	}

	@Override
	public Integer countByCondition(Map<String, Object> map) {
		return repoCatalogResourceDao.countByCondition(map);
	}

	@Override
	public List<RepoCatalogResource> selectAllResourceUnderRepoByPagination(RepoCatalogResource param, Pagination pagination) {
		Map<String,Object> params = MapUtils.newHashMap();


		//2.根据条件查询数目
		MapUtils.putAll(params, param);
		Integer total = repoCatalogResourceDao.countByCondition(params);
		pagination.setTotalCount(total);


		//3.查询列表
		MapUtils.putAll(params, pagination);
		return repoCatalogResourceDao.selectAllResourceUnderRepoByPagination(params);
	}

	@Override
	public void logicDeleteResRelationId(String relationIds) {
		repoCatalogResourceDao.logicDeleteResRelationId(relationIds);
	}


}
